﻿namespace MhAdmin.Web.Core;

/// <summary>
/// 文件管理控制器
/// </summary>
[ApiDescriptionSettings(Tag = "文件管理")]
[Route("dev/[controller]")]
[RolePermission]
public class EmailController : IDynamicApiController
{
    private readonly IEmailService _emailService;

    public EmailController(IEmailService emailService)
    {
        _emailService = emailService;
    }

    #region 查询

    /// <summary>
    /// 邮件推送分页查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("page")]
    public async Task<dynamic> Page([FromQuery] EmailPageInput input)
    {
        return await _emailService.Page(input);
    }

    /// <summary>
    /// 邮件推送列表查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("list")]
    public async Task<dynamic> List([FromQuery] EmailPageInput input)
    {
        return await _emailService.List(input);
    }

    /// <summary>
    /// 邮件推送详情信息
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("detail")]
    public async Task<dynamic> Detail([FromQuery] BaseIdInput input)
    {
        return await _emailService.Detail(input);
    }

    #endregion 查询

    #region 删除

    /// <summary>
    /// 邮件推送删除
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("delete")]
    public async Task Delete([FromBody] List<BaseIdInput> input)
    {
        await _emailService.Delete(input);
    }

    #endregion 删除

    #region 本地邮件

    /// <summary>
    /// 邮件推送发送本地文本邮件
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("sendLocalTxt")]
    public async Task SendLocalTxt([FromBody] EmailLocalSendInput input)
    {
        await _emailService.SendLocalTxt(input);
    }

    /// <summary>
    /// 邮件推送发送本地网络邮件
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("sendLocalHtml")]
    public async Task SendLocalHtml([FromBody] EmailLocalSendInput input)
    {
        await _emailService.SendLocalHtml(input);
    }

    #endregion 本地邮件
}
